#include "userIncludes.hh"
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char** argv){

    try{

        if(argc < 3) {
            cout << "few arguments!" <<endl;
            cout << "Usage: ./test function_name prime function_args..." <<endl;
         
            return 1;   
        }
        vector<string> args;
        int i;
        cout << "args: ";
        for (i=3; i < argc;i++){
            args.push_back(argv[i]);
            cout << argv[i] << ' ';
        }
        cout <<endl;
        cout <<"number of args: " << args.size() << endl;
        //cout <<" arg" << args[0]<<endl;
        
        string name = argv[1];
        userModularFunctionBase* base = userModularFunctionBase::initializeByName(name,args);

        //base->setArguments(args);

        cout << "Resdidue Type: ";
        e_residueType type = base->getResidueType();
        if( type == INTEGER ){
            cout << "integer " << endl;
        }
        else if( type == VECTOR){
            cout << "vector  " << endl;
        }
        else if( type == MATRIX){
            cout << "matrix  " << endl;
        }
        
        cout << "function name: " << base->getName() << endl;
        cout << "files: " ;
        for(size_t i=0; i < base->getFiles().size();i++)
            cout << (base->getFiles()[i]).second << ' ';
        cout << endl;
        fixedBitSizeInteger prime = atoi(argv[2]);
        
        
        
        
        cout << "testing..." << endl;
        base->userModularFunction(prime);
        cout << name << '(' << prime << ") = " << *base << endl;

        delete base;

    }catch (char const* err){cout << err <<endl;}
}
